#include "mainwindow.h"
#include "ui_mainwindow.h"

MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
    , ui(new Ui::MainWindow)
{
    ui->setupUi(this);

    //connect(ui->getPosition_robotleft, &QPushButton::clicked, this, slot4getPosition_robotleft_clicked());
    //ui->getPosition_robotleft->setCheckable(false);

    // 实现按下按钮 和 按回按钮 执行不同的操作

    connect(ui->getPosition_robotleft, &QPushButton::pressed, this, [=](){
        qDebug()<<"this Button has been pressed!";
    });

    connect(ui->getPosition_robotleft, &QPushButton::released, this, [=](){
        qDebug()<<"this Button has been released!";
    });

    connect(ui->getPosition_robotleft, &QPushButton::toggled, this, [=](){
        qDebug()<<"this Button has been toggled!";
    });

    connect(ui->getPosition_robotleft, &QPushButton::clicked, this, [=](){
        if (ui->getPosition_robotleft->isChecked()) {
            ui->position_robotleft->setText("robotleft is true");
            qDebug()<<"true";
        }
        else {
            ui->position_robotleft->setText("robotleft is false");
            qDebug()<<"false";
        }
    });


    //func_ptr = slot4getPosition_robotleft_clicked;
    connect(ui->getPosition_robotleft, SIGNAL(clicked()), this, SLOT(slot4getPosition_robotleft_clicked()));

}

MainWindow::~MainWindow()
{
    delete ui;
}


